home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Commo-Support / Disk-Archive / includes-1_4.dms / includes-1_4.adf / i.zoo / exec / ables.i next >
Encoding:
Text File  |  1989-12-06  |  3.5 KB  |  128 lines

  1.     IFND    EXEC_ABLES_I
  2. EXEC_ABLES_I    SET    1
  3. **
  4. **    $Header: ables.i,v 36.4 89/12/04 21:44:00 bryce Exp $
  5. **
  6. **    Task switch and interrupt control macros
  7. **
  8. **    (C) Copyright 1985,1986,1987,1988,1989 Commodore-Amiga, Inc.
  9. **        All Rights Reserved
  10. **
  11.  
  12.     IFND EXEC_TYPES_I
  13.     INCLUDE "exec/types.i"
  14.     ENDC    ; EXEC_TYPES_I
  15.  
  16.     IFND EXEC_EXECBASE_I
  17.     INCLUDE "exec/execbase.i"
  18.     ENDC    ; EXEC_EXECBASE_I
  19.  
  20.  
  21. *-------------------------------------------------------------------------
  22. *
  23. *   Interrupt Exclusion Macros.  Disable all tasks and interrupts.
  24. *
  25. *-------------------------------------------------------------------------
  26.  
  27. INT_ABLES   MACRO        ; externals used by DISABLE and ENABLE
  28.         XREF    _intena
  29.         ENDM
  30.  
  31. ;Disable interrupts.  Avoid use of DISABLE if at all possible.
  32. ;Please realize the danger of this macro!  Don't disable for long periods!
  33. DISABLE     MACRO   ; [scratchReg],[NOFETCH] or have ExecBase in A6.
  34.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  35.           MOVE.W  #$04000,_intena    ;(NOT IF_SETCLR)+IF_INTEN
  36.           ADDQ.B  #1,IDNestCnt(A6)
  37.           MEXIT
  38.         ENDC
  39.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  40.           MOVE.W  #$04000,_intena
  41.           ADDQ.B  #1,IDNestCnt(\1)
  42.           MEXIT
  43.         ENDC
  44.         IFNC    '\1',''             ;Case 3: Use \1 as scratch
  45.           MOVE.L  4,\1        ;Get ExecBase
  46.           MOVE.W  #$04000,_intena
  47.           ADDQ.B  #1,IDNestCnt(\1)
  48.           MEXIT
  49.         ENDC
  50.         ENDM
  51.  
  52. ;Enable interrupts.  Please realize the danger of this macro!
  53. ENABLE        MACRO   ; [scratchReg],[NOFETCH] or have ExecBase in A6.
  54.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  55.           SUBQ.B  #1,IDNestCnt(A6)
  56.           BGE.S   ENABLE\@
  57.           MOVE.W  #$0C000,_intena    ;IF_SETCLR+IF_INTEN
  58. ENABLE\@:
  59.           MEXIT
  60.         ENDC
  61.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  62.           SUBQ.B  #1,IDNestCnt(\1)
  63.           BGE.S   ENABLE\@
  64.           MOVE.W  #$0C000,_intena
  65. ENABLE\@:
  66.           MEXIT
  67.         ENDC
  68.         IFNC    '\1',''             ;Case 3: Use \1 as scratch
  69.           MOVE.L  4,\1        ;Get ExecBase
  70.           SUBQ.B  #1,IDNestCnt(\1)
  71.           BGE.S   ENABLE\@
  72.           MOVE.W  #$0C000,_intena
  73. ENABLE\@:
  74.           MEXIT
  75.         ENDC
  76.         ENDM
  77.  
  78.  
  79. *-------------------------------------------------------------------------
  80. *
  81. *   Tasking Exclusion Macros.  Forbid all other tasks (but not interrupts)
  82. *
  83. *-------------------------------------------------------------------------
  84.  
  85. TASK_ABLES  MACRO        ; externals used by FORBID and PERMIT
  86.         XREF    _LVOPermit
  87.         ENDM
  88.  
  89. ;Prevent task switching (disables reschedule)
  90. FORBID        MACRO   ; [scratchReg],[NOFETCH] or ExecBase in A6!
  91.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  92.           ADDQ.B  #1,TDNestCnt(A6)
  93.           MEXIT
  94.         ENDC
  95.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  96.           ADDQ.B  #1,TDNestCnt(\1)
  97.           MEXIT
  98.         ENDC
  99.         IFNC    '\1',''             ;Case 3: Use \1 as scratch
  100.           MOVE.L  4,\1    ;Get ExecBase
  101.           ADDQ.B  #1,TDNestCnt(\1)
  102.           MEXIT
  103.         ENDC
  104.         ENDM
  105.  
  106. ;Enable task switching
  107. PERMIT        MACRO   ; [saveFlag],[NOFETCH] or ExecBase in A6!
  108.         IFC     '\1',''             ;Case 1: Assume A6=ExecBase
  109.           JSR     _LVOPermit(A6)
  110.           MEXIT
  111.         ENDC
  112.         IFC     '\2','NOFETCH'      ;Case 2: Assume \1=ExecBase
  113.           EXG.L   A6,\1        ;put execbase in A6
  114.           JSR     _LVOPermit(A6)    ;no registers touched.  A6=ExecBase
  115.           EXG.L   A6,\1
  116.           MEXIT
  117.         ENDC
  118.         IFNC    '\1',''             ;Case 2: save/restore A6
  119.           MOVE.L  A6,-(SP)
  120.           MOVE.L  4,A6
  121.           JSR     _LVOPermit(A6)
  122.           MOVE.L  (SP)+,A6
  123.           MEXIT
  124.         ENDC
  125.         ENDM
  126.  
  127.     ENDC    ; EXEC_ABLES_I
  128.